#include <bits/stdc++.h>
using namespace std;
#define int long long 

int n, m, kmp[1003], to[1003][26], dp[2][1003];
char s[50004], t[1003];

signed main() {
	freopen("neck.in", "r", stdin); freopen("neck.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> (s + 1) >> (t + 1);  n= strlen(s + 1); m = strlen(t + 1);
	int j = 0;
	for (int i = 2; i <= m; ++i) {
		while (j && t[i] != t[j + 1]) j = kmp[j];
		if (t[i] == t[j + 1]) ++j;
		kmp[i] = j;
	}
	for (int i = 0; i < m; ++i) {
		for (int c = 'a'; c <= 'z'; ++c) {
			if (t[i + 1] == c) to[i][c - 'a'] = i + 1;
			else to[i][c - 'a'] = to[kmp[i]][c - 'a'];
		}
	}
	for (int i = n; i >= 1; --i) {
		for (int j = 0; j < m; ++j) {
			dp[i & 1][j] = dp[(i + 1)& 1][j];
			if (to[j][s[i] - 'a'] != m) {
				dp[i & 1][j] = max(dp[i & 1][j], dp[(i + 1) & 1][to[j][s[i] - 'a']] + 1);
			}
		}
	}
	cout << dp[1][0] << "\n";
	return 0;
}
